package id

import "github.com/bwmarrin/snowflake"

// SnowflakeIDGen generates a snowflake id.
type SnowflakeIDGen struct {
	node *snowflake.Node
}

// NewSnowflakeIDGen creates a SnowflakeIDGen.
func NewSnowflakeIDGen(nodeID int64) (*SnowflakeIDGen, error) {
	snowflake.Epoch = 1682524800000
	node, err := snowflake.NewNode(nodeID)
	if err != nil {
		return nil, err
	}
	return &SnowflakeIDGen{
		node: node,
	}, nil
}

// GenerateID creates a snowflake ID.
func (s *SnowflakeIDGen) GenerateID() snowflake.ID {
	return s.node.Generate()
}

// GenerateInt64ID creates a snowflake ID in the format int64.
func (s *SnowflakeIDGen) GenerateInt64ID() int64 {
	return s.node.Generate().Int64()
}
